<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>javascript 阶段</title>
</head>

<body>


    <script>
        // for  in  语句(通常用于循环对象)
        var obj = {
            width: "100px",
            height: "200px",
            background: "red"
        }

        // 写法1:  obj.width 
        // 写法2:  obj["width"]

        // 循环对象 
        // 此处 prop 是自定义的变量名称
        for (var prop in obj) {
            // console.log(prop); // width  , height , background 
            // console.log(obj.prop); // undefined , undefined , undefined
            console.log(obj[prop]);// 100px  200px red
        }


    </script>
</body>

</html>